package com.qinhao.loveCrowdFunding.service;

import com.qinhao.loveCrowdFunding.mapper.SystemDataMapper;
import com.qinhao.loveCrowdFunding.pojo.GetSystemCountDataEntity;
import com.qinhao.loveCrowdFunding.pojo.GetSystemDataCountBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SystemDataService {
    @Autowired
    SystemDataMapper systemDataMapper;

    public Integer getUserCount() {
        GetSystemDataCountBO userCount = systemDataMapper.getUserCount();
        return userCount.getCount();
    }

    public Integer getVisitCount() {
        GetSystemDataCountBO visitCount = systemDataMapper.getVisitCount();
        Integer count = visitCount.getCount() + 1;
        GetSystemCountDataEntity getSystemCountDataEntity = GetSystemCountDataEntity.builder().count(count).build();
        systemDataMapper.updateVisitCount(getSystemCountDataEntity);
        return count;
    }

    public Integer getMessageCount() {
        GetSystemDataCountBO messageCount = systemDataMapper.getMessageCount();
        return messageCount.getCount();
    }


    public Integer getSystemDataStatus() {
        GetSystemDataCountBO systemDataStatus = systemDataMapper.getSystemDataStatus();
        return systemDataStatus.getCount();
    }

    public void updateSystemDataStatus() {
        systemDataMapper.updateSystemDataStatus();
    }
}
